﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ClientWPF.localhost;

namespace ClientWPF
{
    public partial class UsersManagement : Window
    {
        Service1 service = new Service1();
        AuthentificationCredentials authentification = new AuthentificationCredentials();

        public UsersManagement()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            UsersDataGrid.ItemsSource = service.GetAllUsers();
        }

        private void AddUserButton_Click(object sender, RoutedEventArgs e)
        {
            var form = new AddUserForm();
            form.Show();
        }

        private void DeleteUserButton_Click(object sender, RoutedEventArgs e)
        {
            var form = new DeleteUserForm();
            form.Show();
        }

        private void ChangeManagerButton_Click(object sender, RoutedEventArgs e)
        {
            var panel = new AdminPanel();
            Close();
            panel.Show();
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            var form = new MainWindow(); //LogInForm
            Close();
            form.Show();
        }

        private void PrivilegesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selection = (string)((ComboBoxItem)PrivilegesComboBox.SelectedItem).Content;
            User user = new User();
            user.Privileges = selection;
            UsersDataGrid.ItemsSource = service.GetUsersByPrivileges(user);
        }

    }
}
